﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Skybound.Gecko;
using System.IO;
using CrashManager;

namespace NasuTek.Shion
{
    static class Program
    {
        public static bool debug;

        public static Form1 Form1Data;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            if (License.Commands.Verify("NASUTEK", "NasuTek Shion") == true)
            {
                UnhandledExceptionManager.AddHandler(false);
                if (args.Length > 0) { if (args[0] == "/debug") { debug = true; } }
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                if (Directory.Exists(Path.Combine(Application.StartupPath, "xulrunner")) == false)
                {
                    if (MessageBox.Show("Shion needs to download the XULRunner for Shion to operate. After install Shion will relaunch.\nVISTA USERS:\nClick no and rerun as an administrator", "Shion 6", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        Application.Run(new XULRunnerDownloader());
                    }
                }
                else
                {
                    Xpcom.Initialize(Path.Combine(Application.StartupPath, "xulrunner"));
                    Form1Data = new Form1();
                    Application.Run(Form1Data);
                }
            }
            else
            {
                MessageBox.Show("A NasuTek Shion License is missing or failed to verify on the NLS Server. For more information on activation see http://nasutek.com/activation/?o=help.", "NasuTek Shion", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
    }
}
